
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/18 21:05
 */

#include "iostream"

using namespace std;

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    int sum = 0;
    int a[n];
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        sum += a[i];
    }

    int res = 300010;
    int f[sum + 1];
    for (int i = 0; i <= n; ++i) {
        for (int j = sum; j >= 0; --j) {
            if (i == 0 || j == 0) {
                f[j] = 0;
                continue;
            }
            if (j - a[i - 1] >= 0) {
                f[j] = max(f[j], f[j - a[i - 1]] + a[i - 1]);
            }
            if (f[j] >= x) {
                res = min(res, f[j]);
            }
        }
    }

    printf("%d", res);

    return 0;
}